///<reference path="export.d.ts" />
let { ContainerHost, AppSetting, AppService, HelperTool } = NBYC;
class Program {
    async Main() {
        this.init();
        await this.loadSceneProject();
        //this.testMarkupManService();
        //this.testViewManService();
        //this.testGroupManService();
    }
    init() {
        let setting = new AppSetting();
        setting.ViewerScriptBaseUrl = "http://172.16.40.75/apps/ningbo2022/node_modules/";
        setting.ViewerDataBaseUrl = "http://172.16.40.75/apps/ningbo2022/data/";
        setting.ViewerEnableGui = "1";
        setting.ViewerEnableGL2 = false;
        setting.ViewerElementId = "testViewer";
        ContainerHost.Current.Set(AppSetting, () => setting);
    }
    loadSceneProject() {
        let service = ContainerHost.Current.Get(AppService);
        let sceneFile = HelperTool.FromQuery()["scene"];
        if (!sceneFile)
            sceneFile = "data/性能优化版2022-04-13.json";
        return service.LoadFile(sceneFile);
    }
    testViewManService() {
        let viewManService = ContainerHost.Current.Get(NBYC.Services.ViewPointManService);
        if (viewManService.getData().length == 0)
            return;
        let index = 0;
        viewManService.viewSelect(index);
        setInterval(() => {
            index++;
            if (index >= viewManService.getData().length)
                index = 0;
            viewManService.viewSelect(index);
        }, 10000);
    }
    testMarkupManService() {
        let markupManService = ContainerHost.Current.Get(NBYC.Services.MarkupManService);
        markupManService.OnItemClick = (temp) => {
            alert(`${temp.name} 被点击`);
        };

        let red = [255, 0, 0];
        let green = [0, 255, 0];
        let state = false;
        setInterval(() => {
            state = !state;
            markupManService.getData().items.map(_ => {
                _.color = state ? red : green;
            });
            markupManService.updateViewer();
        }, 2000);
    }
    testGroupManService() {
        let groupManService = ContainerHost.Current.Get(NBYC.Services.GroupManService);
        let red = [255, 0, 0];
        let green = [0, 255, 0];
        let state = false;
        setInterval(() => {
            state = !state;
            groupManService.getData().groups.map(_ => {
                _.color = state ? red : green;
            });
            groupManService.updateViewer();
        }, 5000);
    }
}
new Program().Main();